<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\Station\Summary;
use Illuminate\Support\Facades\Auth;

/**
 * 报岗管理
 *
 * Date: 02/05/2018
 * @author George
 * @package App\Http\Controllers
 */
class ReportController extends Controller
{
	public function station()
	{

	}

	/**
	 * 获取报岗汇总数据
	 *
	 * Date: 02/05/2018
	 * @author George
	 * @param Request $request
	 * @return \Illuminate\Http\JsonResponse
	 */
	public function summary(Request $request)
	{
		$start = $request->get('start');
		$end = $request->get('end');
		$project_id = $request->get('project_id');
		$paginate = $request->get('paginate', 15);
		$query = Summary::query()->where('company_id', Auth::user()->company_id);

		if ($start && $end) {
			$query->whereBetween('created_at', [$start, $end]);
		}

		if ($project_id) {
			$query->where('project_id', $project_id);
		}

		return success($query->paginate($paginate));
	}
}
